package com.hxd.otc.base;

import android.content.Intent;
import android.support.annotation.NonNull;

import com.hxd.otc.api.Constant;
import com.hxd.otc.module.login.activity.PhoneCodeActivity;
import com.hxd.otc.mvp.base.BasePresenter;


/**
 * 作  者 :  胡庆岭
 * 时  间 :  2018/5/21 12:02
 * 描  述 :  ${TODO} 手机区号处理类（可以选择性继承）
 */
public abstract class BasePhoneCodeActivity<P extends BasePresenter> extends BaseActivity<P>{


    protected void startPhoneCodeActivity() {
        $startActivityForResult(PhoneCodeActivity.class, Constant.Login.LOGIN_TO_PHONE_CODE_REQUEST_CODE);
    }

    protected void setPhoneCodeResult(@NonNull String phoneCode) {
        Intent intent = new Intent();
        intent.putExtra(Constant.Login.PHONE_CODE_DATA, phoneCode);
        $setResult(intent, true);
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK) {
            switch (requestCode) {
                case Constant.Login.LOGIN_TO_PHONE_CODE_REQUEST_CODE:
                    onPhoneCodeResult(data.getStringExtra(Constant.Login.PHONE_CODE_DATA));
                    break;
            }
        }
    }

    protected  void onPhoneCodeResult(@NonNull String phoneCode){}

}
